<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>themes/standard/css/backend/style.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>js/jquery-ui-1.9.0/css/ui-lightness/jquery-ui-1.9.0.custom.min.css" />
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/jquery-ui-1.9.0/js/jquery-1.8.2.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/jquery-ui-1.9.0/js/jquery-ui-1.9.0.custom.min.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/ckeditor/ckeditor.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/ckfinder/ckfinder.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/tab/jquery.tabs.pack.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/validation/jquery.validate.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>js/tab/jquery.tabs.css" />
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>js/vtab/css/jquery-jvert-tabs-1.1.4.css" />
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/vtab/js/jquery-jvert-tabs-1.1.4.js"></script>
<link rel="stylesheet" type="text/css" href="<?php echo base_url(); ?>js/selectbox/jquery.selectBox.css" />
<script type="text/javascript" language="javascript" src="<?php echo base_url(); ?>js/selectbox/jquery.selectBox.js"></script>
<!-- Start Dialog -->
<link rel="stylesheet" href="<?php echo BASE_URL; ?>js/dialog/css/style.css" />
<script src="<?php echo BASE_URL; ?>js/dialog/js/sp_block.js" type="text/javascript"></script>
<!-- End Dialog -->
<!-- Start Dialog -->
<link rel="stylesheet" href="<?php echo BASE_URL; ?>js/selectbox/jquery.selectBox.css" />
<script src="<?php echo BASE_URL; ?>js/selectbox/jquery.selectBox.js" type="text/javascript"></script>
<!-- End Dialog -->
<!-- Start Tip -->
<link rel="stylesheet" href="<?php echo BASE_URL; ?>js/tipsy/tipsy.css" />
<script src="<?php echo BASE_URL; ?>js/tipsy/jquery.tipsy.js" type="text/javascript"></script>
<script src="<?php echo BASE_URL; ?>js/library.js" type="text/javascript"></script>
<!-- End Tip -->
<script type="text/javascript">
    if (typeof BASE_URL == 'undefined') {
        var BASE_URL = '<?php echo BASE_URL; ?>';
    }
    var SESSION_KEY = '<?php echo session_key(); ?>';
    $(document).ready(function() {
        $('.icon').tipsy({gravity: 's'});
        $(".date_picker").datepicker({"dateFormat": "dd/mm/yy"});
        $("select").selectBox();
        $(".gridview tbody tr td :checkbox").each(function() {
            var checked = $(this).attr("checked");
            if (checked) {
                $(this).parent().parent().addClass("selected");
            } else {
                $(this).parent().parent().removeClass("selected");
            }
        });
        $(".gridview tbody tr td :checkbox").change(function() {
            var checked = $(this).attr("checked");
            if (checked) {
                $(this).parent().parent().addClass("selected");
            } else {
                $(this).parent().parent().removeClass("selected");
            }
        });
        $(".gridview tbody tr.filters td").click(function() {
            $(this).parent().removeClass("selected");
        });
        $(".error_message, .success_message, label.error").click(function() {
            $(this).fadeOut(300);
        });
        $(".tab_container").tabs();
        $(".tabs-nav li:first a").trigger("click");
        $(".ajax_link").click(function() {
            var url = $(this).attr("href");
            var data = $(this).attr("data");
            var selector = $(this).attr("selector");
            var item = $(this).attr("item");
            $.ajax({
                url: url,
                type: 'POST',
                data: data,
                success: function(html) {
                    $(selector).html(html);
                    $(item).trigger("click");
                    if ($(".delete_btn").size() > 0) {
                        $(".delete_btn").show();
                    }
                },
                error: function (xhr, ajaxOptions, thrownError) {
                    alert(xhr.status + ' : ' + thrownError);
                }
            });
            return false;
        });
        $(".active_item").click(function() {
            var item = $(this).attr("item");
            $(item).trigger("click");
            return false;
        });
        $("#loading_process").ajaxStart(function(){
            $(this).show();
        }).ajaxStop(function() {
            $('.icon').tipsy({gravity: 's'});
            $(this).hide();
            $(".date_picker").datepicker({"dateFormat": "dd/mm/yy"});
            $("select").selectBox("destroy");
            $(".selectBox-dropdown, .selectBox-dropdown-menu").remove();
            $("select").selectBox();
            $(".gridview tbody tr td :checkbox").each(function() {
                var checked = $(this).attr("checked");
                if (checked) {
                    $(this).parent().parent().addClass("selected");
                } else {
                    $(this).parent().parent().removeClass("selected");
                }
            });
            $(".gridview tbody tr td :checkbox").change(function() {
                var checked = $(this).attr("checked");
                if (checked) {
                    $(this).parent().parent().addClass("selected");
                } else {
                    $(this).parent().parent().removeClass("selected");
                }
            });
            $(".gridview tbody tr td").click(function() {
                $(this).parent().parent().find("tr").removeClass("selected");
                $(this).parent().addClass("selected");
            });
            $(".gridview tbody tr.filters td").click(function() {
                $(this).parent().removeClass("selected");
            });
            $(".error_message, .success_message, label.error").click(function() {
                $(this).fadeOut(300);
            });
        });
        $(".date_picker").datepicker();
        //$("select").selectBox();
        var editors = $(".editor");
        if ($(editors).size() > 0) {
            $(editors).each(function() {
                var name = $(this).attr("name").toString();
                if (name.length > 0) {
                    CKEDITOR.replace(name, {
                        skin : 'office2003',
                        height : '500px',
                        filebrowserBrowseUrl : '<?php echo base_url(); ?>js/ckfinder/ckfinder.html',
                        filebrowserImageBrowseUrl : '<?php echo base_url(); ?>js/ckfinder/ckfinder.html?type=Images',
                        filebrowserFlashBrowseUrl : '<?php echo base_url(); ?>js/ckfinder/ckfinder.html?type=Flash',
                        filebrowserUploadUrl : '<?php echo base_url(); ?>js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Files',
                        filebrowserImageUploadUrl : '<?php echo base_url(); ?>js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Images',
                        filebrowserFlashUploadUrl : '<?php echo base_url(); ?>js/ckfinder/core/connector/php/connector.php?command=QuickUpload&type=Flash'
                    });
                }
            });
        }
        $("form.ajax_form").submit(function() {
            var data = $(this).serialize();
            data += "&ajax_action=true";
            var action = $(this).attr("action");
            var result_id = $(this).attr("data-result-id");
            $.ajax({
                type: "POST",
                url: action,
                data: data
            }).done(function(output) {
                $("#" + result_id).html(output);
                $(".ajax_link").click(function() {
                    $(this).parent().parent().parent().parent().find("tr").removeClass("selected");
                    $(this).parent().parent().parent().addClass("selected");
                    var url = $(this).attr("href");
                    var data = $(this).attr("data");
                    var selector = $(this).attr("selector");
                    var item = $(this).attr("item");
                    $.ajax({
                        url: url,
                        type: 'POST',
                        data: data,
                        success: function(html) {
                            $(selector).html(html);
                            $(item).trigger("click");
                        },
                        error: function (xhr, ajaxOptions, thrownError) {
                            alert(xhr.status + ' : ' + thrownError);
                        }
                    });
                    return false;
                });
                $(".gridview tbody tr td :checkbox").each(function() {
                    var checked = $(this).attr("checked");
                    if (checked) {
                        $(this).parent().parent().addClass("selected");
                    } else {
                        $(this).parent().parent().removeClass("selected");
                    }
                });
                $(".gridview tbody tr td :checkbox").change(function() {
                    var checked = $(this).attr("checked");
                    if (checked) {
                        $(this).parent().parent().addClass("selected");
                    } else {
                        $(this).parent().parent().removeClass("selected");
                    }
                });
                $(".gridview tbody tr td").click(function() {
                    $(this).parent().parent().find("tr").removeClass("selected");
                    $(this).parent().addClass("selected");
                });
                $(".gridview tbody tr.filters td").click(function() {
                    $(this).parent().removeClass("selected");
                });
                $(".error_message, .success_message, label.error").click(function() {
                    $(this).fadeOut(300);
                });
            });
            return false;
        });
    });
</script>
<script src="<?php echo BASE_URL; ?>js/admin/util.js" type="text/javascript"></script>
